package com.glx.learn_spring.learn_spring_04_bean_lifecycle;

import com.glx.learn_spring.learn_spring_04_bean_lifecycle.dao.IBookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author haoli
 * @create 2022/11/30 13:52
 */
public class AppForLifeCycle {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        //设置容器关闭钩子，可以让虚拟机关闭之前先关闭容器
        ctx.registerShutdownHook();

        IBookDao bookDao = ctx.getBean("bookDao", IBookDao.class);
        bookDao.save();

        //这个方法关闭容器比较暴力
        //ctx.close();


    }
}
